package guda.house.biz.form.bill;

import guda.house.biz.util.PriceUtil;
import guda.house.dal.dataobject.AccountEstateDO;

import javax.validation.constraints.NotNull;
import java.text.SimpleDateFormat;

/**
 * Created by well on 15/11/16.
 */
public class AccountEstateEditForm extends AccountEstateForm{
    @NotNull(message = "不能为空")
    private Long accountId;


    public Long getAccountId() {
        return accountId;
    }

    public void setAccountId(Long accountId) {
        this.accountId = accountId;
    }

    public AccountEstateDO toDO(){
        AccountEstateDO accountEstateDO = super.toDO();
        accountEstateDO.setAccountId(accountId);
        return accountEstateDO;
    }

    public void initForm(AccountEstateDO accountEstateDO){
        setAccountId(accountEstateDO.getAccountId());
        setAccountType(accountEstateDO.getAccountType());
        setAccountMoney(PriceUtil.formatCNY(accountEstateDO.getAccountMoney()));
        setAccountComment(accountEstateDO.getAccountComment());
        setVillageId(accountEstateDO.getVillageId());

        if(accountEstateDO.getGmtAccount()!=null) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            setGmtAccount(simpleDateFormat.format(accountEstateDO.getGmtAccount()));
        }
    }
}
